package kr.co.handysoft.smartPolice.server;

import java.io.File;
import java.io.IOException;
import java.util.List;

import kr.co.handysoft.common.registry.SmartPoliceRegistry;
import kr.co.handysoft.common.server.ControlServer;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.xpath.XPath;

public class WatchingDeamon {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		SAXBuilder builder = new SAXBuilder();
		
		try {
			
			String configFullPath = System.getProperty("deamon.config");
			Document doc = builder.build(new File(configFullPath));
			SmartPoliceRegistry.setDocument(doc);
			List<Element> dirList = XPath.selectNodes(doc, "//directorys/directory" );	
			
			for (Element dirElement : dirList){
				new WatchingThread(dirElement).start();
			}
			
		} catch (JDOMException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
